home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7758 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  42 lines

  1. Path: andrew.cmu.edu!postman+
  2. From: Jim_Mann@transarc.com
  3. Newsgroups: comp.lang.c
  4. Subject: Re: why arrays may seem like pointers (was: What is &Variable ... )
  5. Date: Wed, 28 Feb 1996 14:38:49 -0500
  6. Organization: Carnegie Mellon, Pittsburgh, PA
  7. Message-ID: <MlB_x9_SMUE45Cwf9Q@transarc.com>
  8. References: <4gsdno$1bg@umbc9.umbc.edu> <4gtab6$acb@ceylon.gte.com> <313318b8.53776146@nntp.ix.netcom.com>
  9.     <DnHyrp.CF8@eskimo.com>
  10. NNTP-Posting-Host: po6.andrew.cmu.edu
  11. In-Reply-To: <DnHyrp.CF8@eskimo.com>
  12.  
  13. scs@eskimo.com (Steve Summit) writes:
  14. > I know of at least two reasons why confusion here persists.
  15.  
  16. I think there are serveral others, mostly dealing with common methods
  17. of using arrays and pointers.
  18.  
  19. First of all, if I declare
  20.  
  21.   char foo[20];
  22.  
  23. I can access elements using *foo.
  24.  
  25. Similarly, if I declare (and later allocate)
  26.  
  27.   char *foo;
  28.  
  29. I can acess elements as foo[3];
  30.  
  31. Also, if I declare fooA as an array and fooP as a pointer, I can
  32. make assigments like fooP = fooA.
  33.  
  34. For reasons like this, many newer C programmers get to thinking that
  35. arrays and pointers are pretty much the same thing. 
  36.  
  37. ******************************************************************
  38. Jim Mann                jmann@transarc.com
  39. Transarc Corporation            
  40. The Gulf Tower, 707 Grant Street, Pittsburgh, PA 15219  (412) 338-4442 
  41. WWW Homepage: http://www.transarc.com/~jmann/Home.html
  42.